<?php

namespace Web\MainSiteBundle\Controller;



use Model\NewsBundle\Entity\News;
use Model\NewsBundle\Model\NewsModel;
use Model\NewsCategoryBundle\Model\NewsCategoryModel;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\HttpFoundation\Request;

/**
 * @route("news")
 */
class NewsController extends WebBaseController
{
    /**
     * @route("/{id}",name="WebNews")
     */
    public function WebNews(Request $request , News $news)
    {
        //边栏数据
        $link = "page";//单页栏目所在分组link参数为page
        $newsCategoryModel = new NewsCategoryModel($this->getDoctrine());
        $category = $newsCategoryModel->getNewsCategoryByLink($link);
        $cid = $category["id"];
        $newsModel = new NewsModel($this->getDoctrine());
        $list = $newsModel->getNewsByCategory($cid);
        $data["side"] = array_slice($list,0,10);

        $data["news"] = $news;
        return $this->render("WebMainSiteBundle:Web:news.html.twig",$data);
    }
}
